package _1Class;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

public class TestDemo {

	public static void main(String[] args) throws ClassNotFoundException, FileNotFoundException, IOException, InstantiationException, IllegalAccessException {
		
		
//		Person p = new Person();
		
		// 类对象
		
		// 1. 通过Class.forName得到类对象
//		Class c1 = Class.forName("_1Class.Person");
//		
//		System.out.println(c1);

		// 2. 
//		Person p = new Person();
//		Class c2 = p.getClass();
//		System.out.println(c2);
		
		
		// 3.
//		System.out.println(Person.class);
		
		
//		Person p2 = (Person)c1.newInstance();
//		System.out.println(p2);
		
		
		
		// 举例: 根据配置创建那种类对象
		Properties p = new Properties();
		p.load(new FileInputStream("settings.txt"));
		System.out.println(p.getProperty("name"));
		
		Class c1 = Class.forName(p.getProperty("name"));
		Object o = c1.newInstance();
		System.out.println(o);
	}


}
